package com.za.wbw.web.wap.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;

import com.za.wbw.model.wap.vo.CommentListVo;
import com.za.wbw.model.wap.vo.ProductSellVo;
import com.za.wbw.model.wap.vo.ProductVo;
import com.za.wbw.service.wap.CommentService;
import com.za.wbw.service.wap.ProductService;
import com.za.wbw.util.BaseAction;

public class ProductAction extends BaseAction {
	
	private static final long serialVersionUID = 1L;
	
	private ProductService productService;
	private CommentService commentService;

	public String queryProductPage() throws Exception{
		int total = this.getProductService().queryProductSellCount(1);
		List<ProductSellVo> list = this.getProductService().queryProductSellPage(null);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("total", total);
		map.put("data", list);
		JSONArray json = JSONArray.fromObject(map);
		outPrint(json);
		return null;
	}
	public String queryProductInfo() throws Exception{
		ProductVo vo = this.getProductService().queryProductInfo(0);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("info", vo);
		int count = this.getCommentService().queryCommentCount();
		map.put("comment_count", count);
		List<CommentListVo> commentVos = this.getCommentService().queryCommentList(0);
		map.put("comment_list", commentVos);
		JSONArray json = JSONArray.fromObject(map);
		outPrint(json);
		return null;
	}
	
	public ProductService getProductService() {
		return productService;
	}
	public void setProductService(ProductService productService) {
		this.productService = productService;
	}
	public CommentService getCommentService() {
		return commentService;
	}
	public void setCommentService(CommentService commentService) {
		this.commentService = commentService;
	}
}
